package com.icinfo.cloud.provider.punish.actscode.controller;

import com.icinfo.cloud.provider.common.constant.Constant;
import com.icinfo.cloud.provider.punish.actscode.dto.ActsCodeRequest;
import com.icinfo.cloud.provider.punish.actscode.dto.CasePunishInfoListQueryDto;
import com.icinfo.cloud.provider.punish.actscode.service.ICaseActsCodeService;
import com.icinfo.cloud.provider.punish.actscode.vo.*;
import com.icinfo.cloud.provider.punish.api.vo.CaseActsCodeDetailInfoVo;
import com.icinfo.framework.common.web.Result;
import org.apache.commons.lang3.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 移动端，行为码案件对外接口
 * @Author mahan
 * @Date 2022/11/9
 */
@RestController
@RequestMapping("/app/case/actsCode")
public class CaseActsCodeController {
    @Resource
    private ICaseActsCodeService caseActsCodeService;


    /**
     * 掌上执法，获取案件详情
     * @param caseActsCode
     * @return
     */
    @GetMapping("/getCaseDetailByActsCode")
    public Result<CaseActsCodeDetailVo> getCaseDetailByActsCode(@RequestParam String caseActsCode) {
        return Result.success(Constant.STRING_GET_SUCCESS, caseActsCodeService.getCaseDetailByActsCode(caseActsCode));
    }

    /**
     * 检查详情页面，获取行政处罚列表
     * @param dto
     * @return
     */
    @PostMapping("/getPunishInfoList")
    public Result<List<CasePunishInfoListVo>> getPunishInfoList(@RequestBody CasePunishInfoListQueryDto dto) {
        return Result.success(Constant.STRING_GET_SUCCESS, caseActsCodeService.getPunishInfoList(dto));
    }

    /**
     * 公众扫码，获取案件公示信息
     * @param caseActsCode
     * @return
     */
    @GetMapping("/getCasePublicInfo")
    public Result<CasePublicInfoVo> getCasePublicInfo(@RequestParam String caseActsCode) {
        return Result.success(Constant.STRING_GET_SUCCESS, caseActsCodeService.getCasePublicInfo(caseActsCode));
    }
    /**
     * 获取案件详【V1.1.0行政行为码】
     * @param dto
     * @return
     */
    @PostMapping("/getCaseDetailInfoByActsCode")
    public Result<CaseDetailActsCodeVo> getCaseDetailInfoByActsCode(@RequestBody @Validated ActsCodeRequest dto) {
        return Result.success(Constant.STRING_GET_SUCCESS, caseActsCodeService.getCaseDetailInfoByActsCode(dto));
    }
    /**
     * 获取案件公示状态【V1.1.0行政行为码】
     * @param dto
     * @return
     */
    @PostMapping("/getCasePublicityByActsCode")
    public Result<CasePublicityActsCodeVo> getCasePublicityByActsCode(@RequestBody @Validated ActsCodeRequest dto) {
        return Result.success(Constant.STRING_GET_SUCCESS, caseActsCodeService.getCasePublicityByActsCode(dto));
    }
    /**
     * 通过身份证或者统一社会信用代码获取该身份的partyId公示状态【V1.1.0行政行为码】
     * @param dto
     * @return
     */
    @PostMapping("/getCasePartyIdsByActsCode")
    public Result<List<String>> getCasePartyIdsByActsCode(@RequestBody @Validated ActsCodeRequest dto) {
        if(StringUtils.isBlank(dto.getIdnum()) || StringUtils.isBlank(dto.getUniCode())){
            Result.error("统一社会信用代码或者身份证号不能为空");
        }
        return Result.success(Constant.STRING_GET_SUCCESS, caseActsCodeService.getCasePartyIdsByActsCode(dto));
    }
}
